package com.ansys.demo.controller;

import com.ansys.demo.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: panghai
 * @Date: 2022/04/04/19:56
 * @Description: 文件上传接口
 */
@Controller
public class UploadFileController {

    @Autowired
    private FileService uploadFileService;

    @GetMapping("uploadFile")
    public String updateFile(){
        return "uploadFile";
    }

    @PostMapping("/upload")
    public String upload(@RequestParam("uploadFile") MultipartFile file) throws Exception {
        uploadFileService.uploadFile(file);
        return "ok.html";
    }
}
